<template>
  <div class="Auditinglist">
    <List
      :linklist="linklist"
      :tableData="tableData"
      :btnList="btnList"
      :titleList="titleList"
      :isCheck="isCheck"
    />
    <Paging :total="totalSize" @getLimit="getLimit" @getPage="getPage" />
  </div>
</template>

<script>
import List from "../../components/List.vue";
import Paging from "../../components/Paging.vue";
// import { AuditingListAxios } from "../../http/apis/customerseasApi";
import {mapActions } from "vuex";
import { timeFormat } from "../../utils/utils";
export default {
  name: "Auditinglist",
  components: {
    List,
    Paging,
  },
  props: {
    checkVal: Array,
  },
  data() {
    return {
      currentPage: 1, //当前页
      pageSize: 3, //页数
      totalSize: 0,
      tableData: [
        {
          // customer_name: "xx",
          // contact_name: "张三",
          // contact_phone: "17899977654",
          // contact_email: "123",
          // postalcode: "610000",
          // qq:"123",
          // post_code:"456",
          // origin:"",
          // type:"",
          // address:"成都",
          // import_Date: "2021-12-1",
          // update_Date: "2021-12-2",
          // applicant: "超级管理员",
          // applicationtime: "2021-12-1",
          // remark:"备注"
        },
      ],
      linklist: [
        {
          id: "0",
          name: "客户名称",
          isRouter: false,
          url: "/information/seasinformation",
        },
        {
          id: "1",
          name: "联系人",
          isRouter: false,
        },
        {
          id: "2",
          name: "手机号码",
          isRouter: false,
        },
        {
          id: "3",
          name: "电子邮箱",
          isRouter: false,
        },
        {
          id: "4",
          name: "qq",
          isRouter: false,
        },
        {
          id: "5",
          name: "邮编",
          isRouter: false,
        },
        {
          id: "6",
          name: "客户来源",
          isRouter: false,
        },
        {
          id: "7",
          name: "客户类型",
          isRouter: false,
        },
        {
          id: "8",
          name: "地址",
          isRouter: false,
        },
        {
          id: "9",
          name: "录入时间",
          isRouter: false,
        },
        {
          id: "10",
          name: "最后更新",
          isRouter: false,
        },
        // {
        //   id: "11",
        //   name: "申请人",
        //   isRouter: false,
        // },
        // {
        //   id: "12",
        //   name: "申请时间",
        //   isRouter: false,
        // },
      ],
      btnList: [
        {
          id: "1",
          name: "通过",
          type: "公海",
        },
        {
          id: "2",
          name: "拒绝",
          type: "公海",
        },
      ],
      titleList: [
        "customer_name", //客户名称
        "contact_name", //联系人
        "contact_phone", //手机号码
        "contact_email", //电子邮箱
        "qq",
        "post_code", //邮编
        "origin", //客户来源
        "type", //客户类型
        "address", //详细地址
        "import_Date", //录入时间
        "update_Date", //更新时间
        // "applicant",//申请人
        // "applicationtime",//申请时间
        "remark", //备注
        "application_status", //状态
        "cp_id",
        "employee_id",
        "customer_records_id", //记录id
      ],
      isCheck: true,
      statusval: 0,
    };
  },
  created() {
    this.AuditingList();
  },
  methods: {
    ...mapActions("customerSeasStore", ["AuditingListAction"]),
    // 分页
    getPage(val) {
      console.log(val);
      this.currentPage = val;
      this.AuditingList();
    },

    getLimit(val) {
      console.log(val);
      this.pageSize = val;
      this.AuditingList();
    },

    getCheck(val) {
      this.checkVal = val;
    },

    AuditingList() {
      this.tableData = [];
      this.AuditingListAction({
        data: {},
        currentPage: this.currentPage,
        pageSize: this.pageSize,
      })
        .then((res) => {
          console.log("请求成功:", res.data);
          // console.log(this.currentPage, this.pageSize);
          let arr = res.data.data.list; //将后端数据放入新数组
          arr.forEach((item) => {
            //遍历
            let obj = {
              customer_id: item.customer.customer_id,
              customer_name: item.customer.customer_name, //客户名称
              // contact_name: item.customer.contact[0].contact_name, //联系人
              // contact_phone: item.customer.contact[0].contact_phone, //电话号码
              // contact_email: item.customer.contact[0].contact_email, //电子邮箱
              post_code: item.customer.post_code, //邮编
              origin: item.customer.origin, //客户来源
              type: item.customer.type, //客户类型
              import_Date: timeFormat(
                item.customer.customer_records.import_date
              ), //录入时间
              update_Date: timeFormat(
                item.customer.customer_records.update_date
              ), //更新时间
              remark: item.customer.remark, //备注
              address: item.customer.address, //地址
              // qq: item.customer.contact[0].contact_qq,
              application_status: item.application_status, //状态
              cp_id: item.cp_id,

              employee_id: item.employee.employee_id,
            };
            // 将数据加入显示表中
            this.tableData.push(obj);
          });
          // 计算条数
          this.totalSize = res.data.data.totalSize;
        })
        .catch((err) => {
          console.log("请求失败:", err);
        });
    },
  },
};
</script>

<style lang="scss">
</style>